<?php

namespace app\controllers;

use app\controllers\action\User;
use core\controller\Controller;
use db\Conn;

class login implements Controller
{
    public static function execute()
    {
        $return = ["code" => 400, "data" => [], "msg" => "未登录"];
        /* @var \mysqli $conn */
        $conn = Conn::execute();
        if (User::login($conn ,$_POST["id"], $_POST["password"])) {
            $return["code"] = 200;
            $return["msg"] = "登录成功";
            $return["data"] = $_SESSION;
        }
        $conn->close();

        return $return;
    }
}